import 'package:erp/main_state.dart';
import 'package:erp/widgets/form1/form_builder.dart';
import 'package:erp/widgets/my_app_bar.dart';
import 'package:erp/widgets/sale_project_detail_list.dart';
import 'package:erp/widgets/sale_project_title.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'controller.dart';

export 'binding.dart';

class SaleProject extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var ms = Get.find<MainState>();
    var controller = Get.find<SaleProjectController>();
    return Scaffold(
      backgroundColor: Color(0xFFF7FAFF),
      appBar: MyAppBar(
        centerTitle: '项目信息',
        titleColor: Colors.black,
      ),
      body: ListView(
        children: [
          SaleProjectTile(title: '市场立项项目信息', padding: EdgeInsets.only(left: 52.w)),
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 52.w),
            child: FormBuilder(
              readOnly: true,
              formManagement: FormManagement(),
              initialValue: controller.saleProjectData,
              children: [
                OptionSelectorFormField(
                  label: '* 所属公司',
                  name: 'company',
                  options: ms.getOptions('company'),
                ),
                ClearableTextFormField(
                  label: '* 项目名称',
                  name: 'projectName',
                ),
                ClearableTextFormField(
                  label: '* 立项编号',
                  name: 'projectNo',
                ),
                ClearableTextFormField(
                  label: '* 销售经理(申请人)',
                  name: 'applyEmp',
                ),
                ClearableTextFormField(
                  label: '* 市场区域',
                  name: 'marketArea',
                ),
                OptionSelectorFormField(
                  label: '* 所属大区',
                  name: 'areaDept',
                  options: ms.getOptions('area_dept'),
                ),
                OptionSelectorFormField(
                  label: '* 投标状态',
                  name: 'bidStatus',
                  options: ms.getOptions('bid_status'),
                ),
              ],
            ),
          ),
          SaleProjectTile(title: '项目基本情况', padding: EdgeInsets.only(left: 52.w)),
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 52.w),
            child: FormBuilder(
              readOnly: true,
              formManagement: FormManagement(),
              initialValue: controller.saleProjectData,
              children: [
                ClearableTextFormField(
                  label: '* 业主单位',
                  name: 'ownUnit',
                ),
                ClearableTextFormField(
                  label: '* 设计单位',
                  name: 'designUnit',
                ),
                ClearableTextFormField(
                  label: '* 总承包单位',
                  name: 'contractUnit',
                ),
                ClearableTextFormField(
                  label: '* 招标单位',
                  name: 'bidUnit',
                ),
                ClearableTextFormField(
                  label: '* 建设地点',
                  name: 'buildAddress',
                ),
                ClearableTextFormField(
                  label: '* 建设阶段',
                  name: 'buildStage',
                ),
                DateSelectorFormField(
                  label: '* 启动时间',
                  name: 'beginTime',
                ),
                DateSelectorFormField(
                  label: '* 预竣工时间',
                  name: 'endTime',
                ),
                ClearableTextareaFormField(
                  label: '* 工期说明',
                  name: 'buildDesc',
                ),
                OptionSelectorFormField(
                  label: '* 建设方式',
                  name: 'buildType',
                  options: ms.getOptions('build_type'),
                ),
                OptionSelectorFormField(
                  label: '* 项目类别',
                  name: 'projectCategory',
                  options: ms.getOptions('project_category'),
                ),
                OptionSelectorFormField(
                  label: '* 主要负责技术部',
                  name: 'chargeDept',
                  options: ms.getOptions('charge_dept'),
                ),
              ],
            ),
          ),
          SaleProjectTile(title: '项目详细情况', padding: EdgeInsets.only(left: 52.w)),
          Container(
            color: Colors.white,
            padding: EdgeInsets.fromLTRB(34.w, 0, 34.w, 20.h),
            child: SaleProjectDetailList(
              saleProjectDetailList: controller.saleProjectDetails,
              readOnly: true,
              onCheck: (item) {
                controller.seeProjectDetail(item);
              },
            ),
          ),
          SaleProjectTile(title: '主要商务情况', padding: EdgeInsets.only(left: 52.w)),
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 52.w),
            child: FormBuilder(
              readOnly: true,
              formManagement: FormManagement(),
              initialValue: controller.saleProjectData,
              children: [
                OptionSelectorFormField(
                  label: '* 项目来源',
                  name: 'projectSource',
                  options: ms.getOptions('project_source'),
                ),
                OptionSelectorFormField(
                  label: '* 项目招投标方式',
                  name: 'bidMode',
                  options: ms.getOptions('bid_mode'),
                ),
                FilterChipFormField(
                  items: controller.docListItems,
                  label: "* 需要材料",
                  name: 'docList',
                ),
                ClearableTextFormField(
                  label: '其他材料',
                  name: 'otherDoc',
                ),
              ],
            ),
          ),
          SaleProjectTile(title: '审批信息', padding: EdgeInsets.only(left: 52.w)),
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(horizontal: 52.w),
            child: FormBuilder(
              readOnly: true,
              formManagement: FormManagement(),
              initialValue: controller.saleProjectData,
              children: [
                ClearableTextFormField(
                  label: '* 项目利润指标',
                  name: 'projectProfitRate',
                ),
                ClearableTextFormField(
                  label: '* 市场营销费用额度',
                  name: 'projectExpenseAmount',
                ),
              ],
            ),
          ),
          SizedBox(height: 200.h)
        ],
      ),
    );
  }
}
